package team.seekers.hula.common.entity.enums;

import com.baomidou.mybatisplus.core.enums.IEnum;
import lombok.Getter;

/**
 * 问题反馈的处理
 */

import java.util.Arrays;

@Getter
public enum UserHulaLevelEnum implements IEnum<Integer> {
    LEVEL_1(1, 0,100, "普通用户"),
    LEVEL_2(2, 100,500, "候浪者"),
    LEVEL_3(3, 500, 2000, "浪者"),
    LEVEL_4(4, 2000, 5000, "飓风"),
    LEVEL_5(5, 5000, 5000, "共生者");

    private int level;

    private Integer score;

    private Integer nextScore;

    private String name;

    UserHulaLevelEnum(int level, Integer score, Integer nextScore, String name) {
        this.level = level;
        this.score = score;
        this.nextScore = nextScore;
        this.name = name;
    }

    @Override
    public Integer getValue() {
        return this.level;
    }



    public static UserHulaLevelEnum UserHulaLevelEnum(int level) {
        return Arrays.stream(values()).filter(e -> e.getLevel() == level).findFirst().orElse(null);
    }

    public static UserHulaLevelEnum UserHulaLevelEnum(String name) {
        return Arrays.stream(values()).filter(e -> e.getName().equalsIgnoreCase(name)).findFirst().orElse(null);
    }

    public static UserHulaLevelEnum getEnumByScore(Double score) {
        if(score < 100){
            return LEVEL_1;
        } else if (score < 500) {
            return LEVEL_2;
        } else if (score < 2000) {
            return LEVEL_3;
        }else if (score < 5000){
            return LEVEL_4;
        }else {
            return LEVEL_5;
        }
    }
}
